﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace DynamicToSql
{
    public interface ILogger
    {
        void Log(IStatement statement);
    }

    public sealed class DebugLogger : ILogger
    {
        public DebugLogger()
        {

        }

        public void Log(IStatement statement)
        {
            Debug.WriteLine(statement.Sql);

            foreach (var param in statement.GetParameters())
                Debug.WriteLine(string.Format("{0}={1}", param.Key, param.Value.Value ?? "NULL"));
  
            Debug.WriteLine(string.Empty);
        }
    }

    public sealed class ConsoleLogger : ILogger
    {
        public ConsoleLogger()
        { 
        
        }

        public void Log(IStatement statement)
        {
            Console.WriteLine(statement.Sql);

            foreach (var param in statement.GetParameters())
                Console.WriteLine(string.Format("{0}={1}", param.Key, param.Value.Value ?? "NULL"));

            Console.WriteLine(string.Empty);
        }
    }
}
